package com.cqjtu.eecs.controller;


import com.cqjtu.eecs.entity.vo.CourseBackGraduateVO;
import com.cqjtu.eecs.exception.ParamsErrorException;
import com.cqjtu.eecs.service.ICourseBackGraduateRequirementTemplateService;
import com.cqjtu.eecs.utils.Assert;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luojun
 * @since 2022-02-28
 */
@RestController
@RequestMapping("/course-back-graduate-requirement-template")
@Api(tags = "毕业要求实现矩阵")
public class CourseBackGraduateRequirementTemplateController {
    private final ObjectMapper objectMapper;
    private final ICourseBackGraduateRequirementTemplateService courseBackGraduateRequirementTemplateService;



    public CourseBackGraduateRequirementTemplateController(
            ObjectMapper objectMapper,
            ICourseBackGraduateRequirementTemplateService courseBackGraduateRequirementTemplateService
    ) {
        this.objectMapper = objectMapper;
        this.courseBackGraduateRequirementTemplateService = courseBackGraduateRequirementTemplateService;
    }

    @ApiOperation("通过专业代码获取毕业要求实现矩阵")
    @GetMapping("/get/{id}")
    public String getCourseBackGraduateRequirementTemplate(@PathVariable("id") String id) throws JsonProcessingException {
        Assert.notNull(id, new ParamsErrorException("id入参不能为null"));
        Assert.notBlank(id, new ParamsErrorException("id入参不能为空"));
        return objectMapper.writeValueAsString(
                courseBackGraduateRequirementTemplateService.getCourseBackGraduateRequirementTemplate(id));
    }
}
